home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: freeGrantedLock.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:51 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "pool.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "semaphore.h"
- #include "link.h"
- #include "lsn.h"
- #include "latch.h"
- #include "bf.h"
- #include "file.h"
- #include "volume.h"
- #include "trans.h"
- #include "consist.h"
- #include "lm_intfuncs.h"
- #include "lm_extfuncs.h"
- #include "fi_extfuncs.h"
- #include "lm_globals.h"
-
-
- void
- freeGrantedLock (
-
- register LOCKENTRY *lockEntry,
- int error
- )
- {
-
- register LOCKHEADER *lockHeader;
- register LOCKMODE lockMode;
-
-
- TRACE(TR_LOCK, TR_LEVEL_1);
-
- /*
- * get a pointer to the lock header
- */
- lockHeader = lockEntry->lockHeader;
- CHECK_LOCKHEADER_MAGIC(lockHeader);
-
- /*
- * check to see if there is an upgrade pending
- */
- if (lockEntry->flags & LOCK_UPGRADE_PENDING) {
-
- /*
- * free the corresponding upgrade entry
- */
- freeUpgradeEntry(lockHeader, lockEntry, error);
- }
-
- /*
- * save the mode of this holder
- */
- lockMode = lockEntry->lockMode;
-
- /*
- * free up the lock entry
- */
- freeLockEntry(lockEntry, error);
-
- /*
- * decrement the number of granted locks
- */
- lockHeader->lockCount--;
-
- /*
- * check to see if there are any locks left on this object
- */
- if (LIST_EMPTY( &(lockHeader->grantedList) ) && LIST_EMPTY( &(lockHeader->waitList))) {
-
- TRPRINT(TR_LOCK, TR_LEVEL_1, ("releasing lockHeader:%x:%x:%x",
- lockHeader->hashList.lockid.lockid.word1,
- lockHeader->hashList.lockid.lockid.word2,
- lockHeader->hashList.lockid.lockid.word3));
-
- /*
- * release the consistency structure
- */
- if (LIST_NOT_EMPTY( &(lockHeader->auxList) )) {
-
- LINKCONSISTREC *consistRec;
-
- /*
- * get a pointer to the consistency record
- */
- consistRec = (LINKCONSISTREC *) FIRST_LIST_ELEMENT( &(lockHeader->auxList) );
- CHECK_LINKCONSISTREC_MAGIC(consistRec);
-
- /*
- * free the structure
- */
- fi_FreeLinkConsist(consistRec);
- }
-
- /*
- * return the header to the pool
- */
- poolMove( &LockHeaderPool, &(lockHeader->hashList.list) );
-
- } else {
-
- TRPRINT(TR_LOCK, TR_LEVEL_2, ("remaining granted holders"));
-
- /*
- * decrement the number of holders of the lock mode
- */
- (lockHeader->modeCount[lockMode])--;
-
- TRPRINT(TR_LOCK, TR_LEVEL_2,
- ("lockCount is %d", lockHeader->modeCount[lockMode]));
-
- /*
- * there can be a new supremum
- */
- if (lockMode == lockHeader->supremum) {
-
- TRPRINT(TR_LOCK, TR_LEVEL_2, ("new supremum"));
-
- /*
- * get the new supremum
- */
- lockHeader->supremum = getLockSupremum(lockHeader);
-
- /*
- * grant upgraders
- */
- if (LIST_NOT_EMPTY( &(lockHeader->upgradeList) )) {
-
- grantLockUpgrades(lockHeader);
- }
-
- /*
- * grant waiters
- */
- if (LIST_NOT_EMPTY( &(lockHeader->waitList) )) {
-
- grantLockWaiters(lockHeader);
- }
- }
- }
- }
-